using JsonServer.Models;
using Microsoft.AspNetCore.Mvc;

namespace JsonServer.Controllers;

[ApiController]
[Route("[controller]")]
public class DemoController : ControllerBase {
    [Route("getWithoutParameter")]
    [HttpGet]
    public ActionResult<DemoModel> GetWithoutParameter() {
        return new DemoModel { Id = 1, Name = "Name 1" };
    }

    [Route("getWithParameter")]
    [HttpGet]
    public ActionResult<DemoModel> GetWithParameter(int id, string name) {
        return new DemoModel { Id = id, Name = name };
    }

    [Route("post")]
    [HttpPost]
    public ActionResult<DemoModel> Post([FromBody] DemoModel model) {
        return new DemoModel { Id = model.Id, Name = model.Name };
    }

    [Route("put")]
    [HttpPut]
    public ActionResult<DemoModel> Put([FromBody] DemoModel model) {
        return new DemoModel { Id = model.Id, Name = model.Name };
    }

    [Route("delete")]
    [HttpDelete]
    public ActionResult<DemoModel> Delete(int id) {
        return new DemoModel { Id = id, Name = $"Name {id}" };
    }
}